import router from "@/router"
import { useUserStore } from "@/store/user"
export const logout = (before?: () => void, after?: () => void) => {
    const store = useUserStore()

    before && before()
    localStorage.removeItem('token')
    // 清除动态路由
    store.menus
        .filter((item) => item.parentId === 0)
        .forEach((item) => {
            router.removeRoute(item.name)
        })
        
    store.menus = []
    store.username = ''

    after && after()
}